package com.catering.controller;

import com.catering.common.core.domain.R;
import com.catering.domain.DishOrder;
import com.catering.domain.Orders;
import com.catering.service.OrderListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/orderList")
public class OrderListController {
    @Autowired
    private OrderListService orderListService;

    //获取所有今日订单的营业额和订单数量
    @GetMapping("/getTodayOrderList")
    @PreAuthorize("@ss.hasPermi('order:todayOrder:index')")
    public R<Map<String, Object>> getToDayOrderList(){
        System.out.println(orderListService.getAllOrderList());
        return R.ok(orderListService.getAllOrderList());
    }

    //获取所有订单详细信息
    @GetMapping("/getDetailsOrder")
    @PreAuthorize("@ss.hasPermi('catering:orderList:list')")
    public R<Map<String, Object>> getDetailsOrder(){
        return R.ok(orderListService.getDetailsOrder());
    }

    //获取所有今日订单详细信息
    @GetMapping("/getTodayDetailsOrder")
    @PreAuthorize("@ss.hasPermi('order:todayOrder:todaylist')")
    public R<List<Orders>> getTodayDetailsOrder(){
        return R.ok(orderListService.getTodayDetailsOrder());
    }

    //获取订单中所下单菜品信息
    @GetMapping("/getDishOrder")
    @PreAuthorize("@ss.hasPermi('order:todayOrder:dishorder')")
    public R<List<DishOrder>> getDishOrder(){
        return R.ok(orderListService.getDishOrder());
    }

    //获取订单中对应的菜品信息
    @GetMapping("/getDishOrderById")
    public R<List<DishOrder>> getDishOrderById(Integer id){
        return R.ok(orderListService.getDishOrderById(id));
    }


    //获取最新一单订单信息
    @GetMapping("/getNewOrders")
    public R<Orders> getNewOrders(){
        return R.ok(orderListService.getNewOrders());
    }

    //模糊搜索所有订单符合条件的订单
    @GetMapping("/getOrderLike")
    public R<List<Orders>> getOrderLike(String message){
        return R.ok(orderListService.getOrderLike(message));
    }

}
